package edu.uts.reekie.designer.model;

import org.eclipse.swt.graphics.Image;

import edu.uts.reekie.designer.ImageHelper;

public class Note extends ViewNode implements Nameable {

	
	private static final long serialVersionUID = 1L;

	private static int count = 0;

	public static String PROPERTY_NAME = "name";
	public static String PROPERTY_TEXT = "text";
	
	private static Image ICON = ImageHelper.createFromResource(Note.class,  "icons/note16.gif");  //$NON-NLS-1$
	
	public Note() {
		super();
		size.width = 50;
		text = "A Note";
	}
	
	@Override
	public Image getIconImage() {
		return ICON;
	}

	@Override
	protected String getNewID() {
		return Integer.toString(count++);
	}
	
	private String text = "";
	
	/**
	 * @param text the text to set
	 */
	public void setText(String text) {
		this.text = text;
		firePropertyChange(PROPERTY_TEXT, null, text); //$NON-NLS-2$//$NON-NLS-1$
	}

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	@Override
	public String getName() {
		return getText();
	}

	@Override
	public void setName(String name) {
		setText(name);

		firePropertyChange(PROPERTY_NAME, null, name); //$NON-NLS-2$//$NON-NLS-1$
	}

	
	

}
